package org.grill.clovercash.accounts;

import java.math.BigDecimal;

import org.joda.time.LocalDate;

public class Transaction {
	public Split[] splits;
	public String description;
	public LocalDate date;
	
	public Transaction(Account source, Account dest, String description, BigDecimal value, LocalDate date) {
		splits = new Split[2];
		splits[0] = new Split(source, value, this);
		source.getSplits().add(splits[0]);
		splits[1] = new Split(dest, value.negate(), this);
		dest.getSplits().add(splits[1]);
		
		
		this.description = description;
		this.date = date;
	}
	
	public Transaction() {
	}

	public Split getOther(Split s) {
		if (splits[0] == s)
			return splits[1];
		return splits[0];
	}
}
